package ar.com.fiuba.ElectronicCircuitAnalyst.infrastructure.db4o.repository.predicate;

import ar.com.fiuba.ElectronicCircuitAnalyst.domain.api.Circuit;
import ar.com.fiuba.ElectronicCircuitAnalyst.domain.exceptions.CircuitElementNotFoundException;

import com.db4o.query.Predicate;

public class RelatedCircuitsPredicate extends Predicate<Circuit> {

	private static final long serialVersionUID = 1L;

	private String circuitElementImplName;

	public RelatedCircuitsPredicate(String circuitElementImplName) {
		super();
		this.circuitElementImplName = circuitElementImplName;
	}

	public boolean match(Circuit circuit) {
		try {
			circuit.getCircuitElementByName(circuitElementImplName);
		} catch (CircuitElementNotFoundException e) {
			return false;
		}
		return true;
	}

}
